﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace G.Service.Data
{
    public class UserData : BaseData
    {
        public void AddUser(string email, string password, string nickname)
        {
            this.Entities.AddToUsers(new User() { Email = email, NickName = nickname, Password = password });
        }

        public User GetUserByEmail(string email)
        {
            return this.Entities.Users.FirstOrDefault(c => c.Email == email);
        }

        public User Login(string email, string password)
        {
            User user = GetUserByEmail(email);
            if (user != null && user.Password == password)
                return user;
            return null;
        }

        public User[] GetAllUsers()
        {
            return this.Entities.Users.ToArray();
        }
    }
}
